package com.download.wangkeke.config;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

@Configurable
@ConditionalOnClass(AopLog.class)
@EnableConfigurationProperties(LogConfig.class)
public class AopLogConfig {
  @Autowired
  private LogConfig logConfig;

  @Bean
  @ConditionalOnMissingBean(LogConfig.class)  // 当容器中没有指定Bean的情况下，自动配置PersonService类
  public AopLog personService(){
    AopLog aopLog = new AopLog(logConfig.getLevel(),logConfig.getType());
    return aopLog;
  }
}
